<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@include file="/resource/common/taglib.jspf"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>添加</title>
<%@include file="/resource/common/jquery.jspf"%>
<%@include file="/resource/common/commonCss.jspf"%>
<%@include file="/resource/common/bootstrap.jspf"%>
<%@include file="/resource/common/validate.jspf"%>
<script type="text/javascript" src="${ctxStatic }/js/system/asyncDoSubmitForm.js"></script>

<link rel="stylesheet" href="${ctxStatic}/plugins/upload/image.css" type="text/css" media="screen" />
<script type="text/javascript" src="${ctxStatic }/plugins/upload/uploadImageUtils.js"></script>

</head>
<body>
	<div id="body-wrapper">
		<div id="main-content">
			<div class="content-box" >
				<div class="content-box-content">
					<div class="tab-content default-tab" id="tab1">
						<fieldset>
							<input type="hidden" id="asyncResult" name="asyncResult" value="-1" /> 
							<input type="hidden" id="asyncResultData" name="asyncResultData" value="-1" /> 
							<input type="hidden" id="asyncResultError" name="asyncResultError" value="-1" /> 
							<form:form id="inputForm" name="form1" class="form-horizontal" method="post" action="addWebAdPhoto.do" modelAttribute="WebAdPhoto">
								<div class="row">
									<div class="col-md-12 col-sm-12 col-xs-12" >
										<input type="hidden" id="id" name="id" value="${entity.id}" /> 
										<div class="form-group">
											<label class="col-md-2 col-sm-2 col-xs-2 control-label">所属广告:<span style="color: red">*</span></label>
											<div class="col-md-10 col-sm-10 col-xs-10">
												<select id="adId" name="adId">
													<c:forEach var="item" items="${list}" varStatus="abc">
														<option value="${item.id }" <c:if test="${item.id == adId }">selected="selected"</c:if>>${item.name }</option>
													</c:forEach>
												</select>
											</div>
										</div>
									<div class="form-group">
										<label class="col-md-2 col-sm-2 col-xs-2 control-label">图片：</label>
										<div class="col-md-10 col-sm-10 col-xs-10">
											<input type="hidden" id="photo" name="photo" value="${entity.photo }"/>
											<input type="hidden" id="filedata" name="filedata" />
											<input type="hidden" id="fileext" name="fileext" />
											<div id="uploadPreview" class="uploadPreview">
												5M大小以内
											</div>
										</div>
									</div>
									<div class="form-group form-group-sm">
										<label for="formGroupInputSmall" class="col-md-2 col-sm-2 col-xs-2 control-label"></label>
										<div class="col-md-10 col-sm-10 col-xs-10">
											<input id="uploadImage" type="file" name="photoimage" class="fimg1" />
										</div>
									</div>
									<div  style="color: red;text-align: center;margin-bottom: 10px;margin-left: -150px;" id="msg"></div>
									
										
										<div class="form-group">
											<label class="col-md-2 col-sm-2 col-xs-2 control-label">跳转地址:</label>
											<div class="col-md-10 col-sm-10 col-xs-10">
												<input type="text" class="form-control input-sm" value="${entity.url}" name="url" id="url"  placeholder="跳转地址"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-md-2 col-sm-2 col-xs-2 control-label">描述:</label>
											<div class="col-md-10 col-sm-10 col-xs-10">
												<input type="text" class="form-control input-sm" value="${entity.description}" name="description" id="description"  placeholder="描述"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-md-2 col-sm-2 col-xs-2 control-label">排序:<span style="color: red">*</span></label>
											<div class="col-md-10 col-sm-10 col-xs-10">
												<input type="text" class="form-control input-sm" value="${entity.sort}" name="sort" id="sort"  placeholder="sort"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-md-2 col-sm-2 col-xs-2 control-label">备注:</label>
											<div class="col-md-10 col-sm-10 col-xs-10">
												<input type="text" class="form-control input-sm" value="${entity.remark}" name="remark" id="remark"  placeholder="备注"/>
											</div>
										</div>
										<div class="form-group">
											<label class="col-md-2 col-sm-2 col-xs-2 control-label">是否开启:</label>
											<div class="col-md-10 col-sm-10 col-xs-10">
												<select name="status" id="status" class="form-control input-sm">
													<option value="true" <c:if test="${entity.status==true }">selected="selected"</c:if>>开启</option>
													<option value="false" <c:if test="${entity.status==false }">selected="selected"</c:if>>关闭</option>
												</select>
											</div>
										</div>
										
									</div>
								</div>
							</form:form>
						</fieldset>
					</div>
				</div>
			</div>
		</div>
	</div>
<script type="text/javascript">
var result = 0;
var validateForm;
$(document).ready(function() {
	validateForm = $("#inputForm").validate({
		rules : {
			adId : {
				required : true
			},
			status : {
				required : true
			},
            sort : {
                required : true
            }
		},
		messages : {
			adId : {
				required : "所属广告不能为空"
			},
            status : {
                required : "是否开启不能为空"
            },
            sort : {
                required : "排序不能为空"
            }
		},
		errorElement : "em",
		errorClass : "validate_error",
		submitHandler: function(form) { //通过之后回调
		},
		invalidHandler: function(form, validator) {
			return false;
		}
	});
	
	
	
});

$(document).ready(function() {
	$("#uploadImage").imageUploadUtils({
		data : "#filedata",
		ext : "#fileext",
		msg : "#msg",
		preview : "#uploadPreview",
	});
	
	var photo = "${entity.photo}";
	var bg = "resource/images/no_photo.png";
	if(photo!=''){
		bg = photo;
	}
	$("#uploadPreview").css("background-image", "url("+bg+")");
});

</script>	
</body>
</html>